#ifndef SRVCONNECTIONLOCAL_H_
#define SRVCONNECTIONLOCAL_H_

#include "scHeader.h"
#include <QMap>
#include <QBuffer>
#include "Database.h"
#include "SrvConnection.h"

struct sqlite3;

namespace sybilpm
{
/**
 */
class SrvConnectionLocal : public SrvConnection
{
	Q_OBJECT

public:
	/**
	 * Create a connection to a local SQLite3 database.
	 *
	 * @param dbFile path and file name of the database to use
	 */
	SrvConnectionLocal(QString dbFile);

	// implementation of SrvConnection
	virtual ~SrvConnectionLocal();
	virtual QString errorString() const;
	// virtual const void * getIdentity() const {return this;}
	virtual bool acceptRequest() const {return true;}
	virtual bool acceptTest() const {return true;}
	virtual bool isTesting() const {return false;}
	virtual unsigned long startTest();
	virtual unsigned long startRequest(RequestDescriptor * requDesc, unsigned long transactionId =0, bool bootTransaction =false);
	virtual QBuffer * getData(unsigned long transId);
	virtual void freeData(unsigned long transId);
	virtual void abortAllTransactions() {return;}

private:
	typedef QMap<unsigned long, QBuffer *> Requests;
	unsigned long createTrans(RequestDescriptor * requDesc, unsigned long transactionId, bool bootTransaction);
	Database db;
	bool testResult;
	Requests requs;
};

} // namespace sybilpm

#endif /*SRVCONNECTIONHTTP_H_*/
